package com.han.memento.white_box;

/**
 * @ClassName Player
 * @Description 游戏玩家（属于发起人角色）
 * @Author duoduo Han
 * @Date 2024/6/22 10:51
 */
public class Player {
    private int vit;//生命
    private int atk;//攻击
    private int def;//防御

    //初始化内部状态
    public void initState() {
        this.vit = 100;
        this.atk = 100;
        this.def = 100;
    }
    //战斗的方法
    public void fight() {
        this.vit = 0;
        this.atk = 0;
        this.def = 0;
    }
    //保存角色状态功能
    public PlayerMemento saveState() {
        return new PlayerMemento(vit, atk, def);
    }
    //恢复角色状态功能
    public void recoveryState(PlayerMemento memento) {
        //将备忘录对象中的状态值赋值给当前对象成员
        this.vit = memento.getVit();
        this.atk = memento.getAtk();
        this.def = memento.getDef();
    }
    //展示状态功能
    public void showState() {
        System.out.println("角色生命力为：" + this.vit);
        System.out.println("角色攻击力为：" + this.atk);
        System.out.println("角色防御力为：" + this.def);
    }

    public int getVit() {
        return vit;
    }

    public void setVit(int vit) {
        this.vit = vit;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }
}
